import { requestClient } from '#/api/request';

// 课程分类树节点接口
export interface SubjectCategoryTreeNode {
  id: string;
  name: string;
  createTime: string;
  pid: string;
  children: SubjectCategoryTreeNode[];
}

// 课程信息接口
export interface CourseInfo {
  id: string;
  icon: string;
  name: string;
  studyCount: number;
  chapterCount: number;
  totalSections: number;
  subjectFullPath: string;
  onlineTime: string;
}

// 分页信息接口
export interface PageInfo {
  curPage: number;
  pageSize: number;
  totalRows: number;
  totalPages: number;
  limit: number;
  offset: number;
}

// 课程列表请求参数接口
export interface CourseListParams {
  keyWord?: string;
  subjectCategoryId?: string;
  courseSortType?: string;
  curPage?: number;
  pageSize?: number;
  totalRows?: number;
  totalPages?: number;
  limit?: number;
  offset?: number;
}

// 课程列表响应接口
export interface CourseListResponse {
  status: number;
  message: string;
  data: CourseInfo[];
  timestamp: number;
  pageInfo: PageInfo;
}

// 获取课程分类树列表（无分页）
export async function getSubjectCategoryTreeListsApi(): Promise<SubjectCategoryTreeNode[]> {
  return requestClient.get('/course/open/get-subject-category-tree-lists');
}

// 获取公开课程信息列表
export async function getPublicCourseInfoListApi(params: CourseListParams): Promise<CourseListResponse> {
  return requestClient.get('/course/open/get-public-course-info-list', {
    params
  });
}
